package com.xiaoming.project.core;

import java.time.LocalDate;

public class LocalDateTest {
    static void localDateYearCheck() {
        LocalDate date28 = LocalDate.of(2020, 2, 28);
        System.out.println(date28.plusYears(1));
        System.out.println(date28.plusYears(4));

        LocalDate date29 = LocalDate.of(2020, 2, 29);
        System.out.println(date29.plusYears(1));
        System.out.println(date29.plusYears(4));

        LocalDate date28After4YearFake = LocalDate.of(2021, 2, 27);
        System.out.println(date28.until(date28After4YearFake).getYears());

        LocalDate date28After4Year = LocalDate.of(2021, 2, 28);
        System.out.println(date28.until(date28After4Year).getYears());
    }

    static void localDateGetMonthDayTest() {
        System.out.println(LocalDate.now().getDayOfMonth());
        System.out.println(LocalDate.now().lengthOfMonth());
    }
}